package o;

import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;

public class HcridSession extends BaseSharedPref {
    private static volatile HcridSession ˊ = null;
    private int ʻ = -1;
    private String ʽ = "#";
    private Map<String, String> ˋ = new ConcurrentHashMap();
    private String ˎ = ʻ();
    private Map<String, String> ॱ = new ConcurrentHashMap();
    private long ॱॱ = -1;
    private long ᐝ = -1;

    private HcridSession() {
    }

    public static synchronized HcridSession ˋ() {
        HcridSession o_cgn;
        synchronized (HcridSession.class) {
            if (ˊ == null) {
                ˊ = new HcridSession();
            }
            o_cgn = ˊ;
        }
        return o_cgn;
    }

    public void ˊ(String str) {
        this.ʽ = str;
    }

    public void ˏ(long j) {
        this.ᐝ = j;
    }

    private String ʻ() {
        Context ˋ = ContentManager.getInstant().getContext();
        String ˊ = doi.ˊ();
        String ˎ = dok.ˎ();
        int ˏ = cdn.ˏ(ˋ);
        int ॱ = azc.ˎ().ॱ();
        String ˊ2 = azc.ˎ().ˊ();
        String str = Build.MODEL;
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(ˊ).append(ˎ).append(ˏ).append(ॱ).append(ˊ2).append(str).append(cdn.ʻ().ᐝ()).append(cdn.ʻ().ʼ());
        return stringBuilder.toString();
    }

    public String ˊ() {
        return ˏ(ccz.ॱ());
    }

    @NonNull
    public String ˏ(int i) {
        return ˏ(ˊ(i));
    }

    @NonNull
    private String ˏ(String str) {
        String str2 = (String) this.ˋ.get(str);
        String ʽ;
        if (str2 == null) {
            str2 = ॱ(str, "");
            if (TextUtils.isEmpty(str2)) {
                str2 = "";
                this.ˋ.put(str, str2);
                return str2;
            }
            ʽ = ʽ();
            if (str2.startsWith(ʽ)) {
                this.ˋ.put(str, str2);
                return str2.substring(ʽ.length());
            }
            str2 = "";
            this.ˋ.put(str, str2);
            Logger.ˎ("HcridSession", "error sign cache in sharedPreference.");
            return str2;
        } else if ("".equals(str2)) {
            return str2;
        } else {
            ʽ = ʽ();
            if (str2.startsWith(ʽ)) {
                return str2.substring(ʽ.length());
            }
            Logger.ˎ("HcridSession", "unfit cache sign value.");
            str2 = "";
            this.ˋ.put(str, str2);
            return str2;
        }
    }

    @NonNull
    private String ʽ() {
        if (this.ᐝ < 0) {
            this.ᐝ = eua.ˏ().ॱ("roam_time", 0);
        }
        if ("#".equals(this.ʽ)) {
            this.ʽ = eua.ˏ().ॱ("physical_address", "");
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(doi.ॱ()).append(bke.ˎ()).append(bke.ˏ()).append(eqp.ॱ()).append(TimeZone.getDefault().getID()).append(dok.ʻ()).append(this.ᐝ).append(this.ʽ).append(eqp.ॱˊ()).append(this.ˎ);
        if (cdn.ʽ()) {
            stringBuilder.append(epv.ʽ(ContentManager.getInstant().getContext()));
        }
        String ˋ = cev.ˋ(stringBuilder.toString());
        StringBuilder stringBuilder2 = new StringBuilder();
        stringBuilder2.append(ˋ).append("#");
        return stringBuilder2.toString();
    }

    public void ˏ(String str, int i) {
        String ˊ = ˊ(i);
        if (!ˏ(ˊ).equals(str)) {
            Map all = this.ˏ.getAll();
            if (all != null && all.size() >= 10) {
                ˏˏ();
            }
            if (str == null) {
                this.ˋ.remove(ˊ);
                ʼ(ˊ);
                ˋ("");
                return;
            }
            String str2 = ʽ() + str;
            ˋ(doi.ॱ());
            this.ˋ.put(ˊ, str2);
            ˋ(ˊ, str2);
        }
    }

    public void ˋ(String str) {
        ˋ("appstore.client.lang.param", str);
    }

    public String ˎ() {
        return ॱ("appstore.client.lang.param", "");
    }

    public String ॱ() {
        return ॱ(ॱॱ());
    }

    public void ˎ(String str) {
        String ॱॱ = ॱॱ();
        if (!ॱ(ॱॱ).equals(str)) {
            if (str == null) {
                this.ॱ.remove(ॱॱ);
                ʼ(ॱॱ);
            } else {
                this.ॱ.put(ॱॱ, str);
                ˋ(ॱॱ, str);
            }
        }
        this.ॱॱ = System.currentTimeMillis();
        eua.ˏ().ˎ("last_set_hcrid_time", this.ॱॱ);
    }

    private String ॱ(String str) {
        String str2 = (String) this.ॱ.get(str);
        if (str2 != null) {
            return str2;
        }
        str2 = ॱ(str, "");
        this.ॱ.put(str, str2);
        return str2;
    }

    private String ˊ(int i) {
        StringBuilder append = new StringBuilder(64).append("appstore.client.sign.param");
        if (dgm.ˋ(i)) {
            append.append(i);
        }
        return append.toString();
    }

    private String ॱॱ() {
        return "appstore.client.hcrId.param" + cdn.ˊ() + eqp.ॱ();
    }

    public void ˋ(int i) {
        this.ʻ = i;
        ˊ("appstore.client.gms.support", i);
    }

    public boolean appsstoreGMSSupport() {
        if (this.ʻ < 0) {
            this.ʻ = ॱ("appstore.client.gms.support", 0);
        }
        if (this.ʻ == 1) {
            return true;
        }
        return false;
    }
}
